<template>
    <div class="ui form">
        <component is="tFields" @onsubmit="onsubmit" @oncancel="oncancel" @onchange="onchange" :data="fileds"
                   :nosubmit="nosubmit"></component>
    </div>
</template>
<script>
    import tool from 'src/util/tool';
    import util from '_util/index';
    import logic from '_logic';

    import tFields from 'components/tunit/tFields'

    export default {
        data() {
            return {
                val: null,
                nosubmit: true,
                productData: {
                    scost_in: {
                        label: "费用包含",
                        name: "scost_in",
                        value: ''
                    },
                    scost_ex: {
                        label: "费用不含",
                        name: "scost_ex",
                        value: ''
                    }
                },
                vo: {}
            }
        },
        components: {
            tFields
        },
        watch: {},
        methods: {
            onchange({name, value}){
                this.productData[name].value = value;
                this.$emit("onchange", {name: 2, data: this.productData});
            },
            oncancel(){
            },
            onsubmit(){
            },
        },
        computed: {
            fileds(){
                let data = [];
                Object.keys(this.productData).forEach(key => {
                    data.push({
                        label: this.productData[key].label,
                        show_type: "textarea",
                        value: this.productData[key].value,
                        name: this.productData[key].name
                    })
                });
                return data
            }
        },
        mounted() {

        },
        props: {
            params: {
                type: Object,
                default: function () {
                    return {}
                }
            }
        },
        created() {
            if (this.params.data[2]) {
                Object.keys(this.params.data[2]).forEach(key => {
                    this.productData[key].value = this.params.data[2][key].value
                })
            }else{
                this.$emit("onchange", {name: 2, data: this.productData});
            }
        },
        mounted(){

        }
    }
</script>
<style rel="stylesheet/less" scoped lang="less">@import "../../../common/style/mixin";

</style>
